package com.haixee.parkdemo.auth.service.impl;

import com.haixee.parkdemo.auth.dao.RoleScopeCustomMapper;
import com.haixee.parkdemo.auth.dao.RoleScopeMapper;
import com.haixee.parkdemo.auth.model.RoleScope;
import com.haixee.parkdemo.auth.service.RoleScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleScopeServiceImpl implements RoleScopeService {


    @Autowired
    private RoleScopeMapper roleScopeMapper;

    @Autowired
    private RoleScopeCustomMapper roleScopeCustomMapper;

    @Override
    public void insertRoleScope(Integer role, byte scope) {
        RoleScope roleScope = new RoleScope();
        roleScope.setRoleId(role);
        roleScope.setDataScope(scope);

        roleScopeMapper.insertSelective(roleScope);
    }

    @Override
    public void setRoleScope(Integer role, byte scope) {

        roleScopeCustomMapper.updateScopeByRole(role, scope);

    }

    @Override
    public Byte getRoleScope(Integer role) {
        return roleScopeCustomMapper.getScopeByRole(role);
    }
}
